package com.iwhalecloud.bss.kite.cucc.service.pay;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Component
public class QryOrderDetailExecutorService {
    private static final int INITIALSIZE  = 5;

    private static final int MAXSIZE = 50;

    private static final long KEEPALIVETIME = 300L;

    private static QryOrderDetailExecutorService instance;

    private final ExecutorService executorService;

    public QryOrderDetailExecutorService(){
        this.executorService = new ThreadPoolExecutor(INITIALSIZE, MAXSIZE, KEEPALIVETIME, TimeUnit.SECONDS, new SynchronousQueue(),
            new CustomizableThreadFactory("QryOrderDetailCaller-Executor"), new ThreadPoolExecutor.CallerRunsPolicy());;
        instance = this;
    }

    public ExecutorService getExecutor(){
        return  this.executorService;
    }

    public static QryOrderDetailExecutorService getInstance(){
        return instance;
    }
}
